package cc.uncarbon.module.appapi.web.app;

import cc.uncarbon.framework.web.model.response.ApiResult;
import cc.uncarbon.module.appapi.constant.AppApiConstant;
import cc.uncarbon.module.appapi.model.request.OrdersItemDTO;
import cc.uncarbon.module.appapi.service.OrdersItemService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Tag(name = "小程序订单预约管理")
@RequestMapping(AppApiConstant.HTTP_API_URL_PREFIX + "/api/v1")
@RequiredArgsConstructor
@RestController
@Slf4j
public class OrdersItemController {
    private final OrdersItemService ordersItemService;

    @Operation(summary = "订单预约")
    @PostMapping("/order/reservation")
    public ApiResult<Long> createOrderItem(@RequestBody @Validated OrdersItemDTO dto) {
        return ApiResult.data(ordersItemService.createOrder(dto));
    }
    @Operation(summary = "确认服务")
    @GetMapping("/order/update")
    public ApiResult updateOrderStatus(@RequestParam Long id){
        return ApiResult.data(ordersItemService.updateOrderStatus(id));
    }
}
